package com.abhimanyu.dataaccess;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.abhimanyu.dataaccess.model.DollarRate;

/**
 * @author Abhimanyu
 * 
 */
@Repository
public class InMemoryDollarRateDao implements IDao<DollarRate> {
	private static List<DollarRate> dollarRates = new ArrayList<DollarRate>();

	public InMemoryDollarRateDao() {

		DollarRate dollarRate = new DollarRate();
		dollarRate.setDate(new Date());
		dollarRate.setDollarRate("50.123");
		dollarRate.setServiceName("Xoom");
		save(dollarRate);

		dollarRate = new DollarRate();
		Date d = new Date();
		d.setMonth(5);
		dollarRate.setDate(d);
		dollarRate.setDollarRate("51.3240");
		dollarRate.setServiceName("Xoom");
		save(dollarRate);
		
		dollarRate = new DollarRate();
		d = new Date();
		//d.setMonth(5);
		dollarRate.setDate(d);
		dollarRate.setDollarRate("54.3240");
		dollarRate.setServiceName("Dollar Rate");
		save(dollarRate);
		
		dollarRate = new DollarRate();
		d = new Date();
		d.setMonth(5);
		dollarRate.setDate(d);
		dollarRate.setDollarRate("49.3240");
		dollarRate.setServiceName("Dollar Rate");
		save(dollarRate);
	}

	public void save(DollarRate dollarRate) {
		dollarRates.add(dollarRate);
		System.out.println("ADDED : " + dollarRate);
	}

	public List<DollarRate> fetchAll() {

		return dollarRates;
	}

	DateFormat format = new SimpleDateFormat();

	public void update(DollarRate object) {
		// TODO Auto-generated method stub

	}

}
